<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/3/3
  Time: 16:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>宿舍管理</title>
    <!--框架必需start-->
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/jquery.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/language/cn.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/framework.js"></script>
    <link href="${pageContext.request.contextPath}/static/qui/libs/css/import_basic.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" id="skin" prePath="${pageContext.request.contextPath}/static/qui/" />
    <link rel="stylesheet" type="text/css" id="customSkin" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/qui/libs/js/popup/toast.js"></script>
    <script src="${pageContext.request.contextPath}/static/qui/libs/js/table/quiGrid.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/qui/libs/js/form/form.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/qui/libs/js/form/validationRule.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/qui/libs/js/form/validation.js" type="text/javascript"></script>


</head>
<body>
<form id="inputFrom" action="/dorm/addDorm" method="post"  showOnMouseOver="false">
    <div class="page_content">
        <table class="formStyle">
            <input type="hidden" name="id" value="" />
                <tr>
                    <td width="110" class="ali03">宿舍号：</td>
                    <td width="200">
                        <input type="text"  id="dormNo" name="dormNo" class="validate[required]"/>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
                <tr>
                    <td width="110" class="ali03">公寓名：</td>
                    <td width="200">
                        <input type="text"  id="flatName" name="flatName" class="validate[required]"/>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
                <tr>
                    <td width="110" class="ali03">室长：</td>
                    <td width="200">
                        <input type="text"  id="dormHead" name="dormHead" class="validate[required]"/>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
                <tr>
                    <td width="110" class="ali03">室长联系方式 ：</td>
                    <td width="200">
                        <input type="text"  id="dormPhone" name="dormPhone" class="validate[required]"/>
                    </td>
                    <td width="15">
                        <span class="star">*</span>
                    </td>
                    <td>
                         <div class="validation_info"></div>
                    </td>
                </tr>
        </table>
    </div>
</form>
<script>
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) return decodeURI(r[2]);
        return "";
    }
    var flag=getQueryString("flag");
    var id=getQueryString("id");
    if(flag==="edit"){
        $("#inputFrom").attr("action","/dorm/editDorm");
        $.getJSON("/dorm/getDormById",{"id":id},
            function(result){
                $('#inputFrom').ajaxWrite({data:result.data});
            },"json");
    }
    function submitHandler(){
        var valid = $('#inputFrom').validationEngine({returnIsValid: true, showOnMouseOver:false});
        if(valid){
            $('#inputFrom').ajaxSubmit({
                //表单提交成功后的回调
                success: function(data, statusText, xhr, $form){
                    if(data.success){
                        top.Toast('showSuccessToast', data.msg);
                        //刷新数据
                        top.frmright.refresh();
                        //关闭窗口
                        top.Dialog.close();
                    }
                    else{
                        top.Toast('showWarningToast', data.msg);
                    }
                }
            });
        }
        return false;
    }
</script>
</body>
</html>
